package com.bnd.domain.session;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.common.Message;
import com.bnd.config.SseEmitterUTF8;
import jakarta.websocket.Session;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class ChatSession extends BaseChatSession{
    private SseEmitterUTF8 sseEmitter;
    private Generation generation;

    public ChatSession(String chatId, Long characterId, Session session){
        this.chatId = chatId;
        this.messageList = CollectionUtil.newArrayList();
        // SSE 超时时间：图片生成为异步且可能>30s，这里将超时提升至180s，避免在图片返回前连接被关闭
        this.sseEmitter = new SseEmitterUTF8(180000L);
        this.generation = new Generation();
        this.characterId = characterId;
    }
}
